import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Home from '@/views/Home'
import Category from '@/views/Category'
import Product from '@/views/Product'
import Cart from '@/views/Cart'
import Pay from '@/views/Pay'
import Result from '@/views/Result'
const Goods = () => import('@/views/goods')

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    children: [
      {
        path: '',
        component: Home
      },
      {
        path: 'category/:id',
        component: Category
      },
      {
        path: '/goods/:id',
        component: Goods
      },
      {
        path: '/product/:id',
        component: Product
      },
      {
        path: '/cart',
        component: Cart
      },
      {
        path: '/pay',
        component: Pay
      },
      {
        path: '/pay/result',
        component: Result
      }

    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
